package com.source.hotelbath;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;

import com.source.hotelbath.fragment.DoneFragment;
import com.source.hotelbath.fragment.LinenFragment;
import com.source.hotelbath.fragment.MineFragment;
import com.source.hotelbath.fragment.OrderFragment;
import com.source.hotelbath.fragment.UndoneFragment;


/**
 * Created by kinglong on 15-1-19.
 */
public class FragmentFactory {
    private final String TAG = FragmentFactory.class.getSimpleName();
    public static FragmentFactory mFragmentFactory;

    private FragmentFactory() {

    }

    public static FragmentFactory getInstance() {
        if (null == mFragmentFactory) {
            mFragmentFactory = new FragmentFactory();
        }
        return mFragmentFactory;
    }


    public Fragment getFragmentByTag(FragmentManager fragmentManager, String tag) {
        Fragment fragment = fragmentManager.findFragmentByTag(tag);
        if (null != fragment) {
            return fragment;
        } else if (tag.equals(LinenFragment.TAG)) {
            fragment = new LinenFragment();
        } else if (tag.equals(MineFragment.TAG)) {
            fragment = new MineFragment();
        } else if (tag.equals(OrderFragment.TAG)) {
            fragment = new OrderFragment();
        }else if(tag.equals(DoneFragment.TAG)){
            fragment=new DoneFragment();
        }else if (tag.equals(UndoneFragment.TAG)){
            fragment=new UndoneFragment();
        }
        return fragment;
    }
}
